import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;

class ToolBarListener implements ActionListener
	{
		JButton add;
		JButton edit;
		JButton remove;
		JComboBox viewSelector;
		EventsView eV;
		Application controller;
		
		ToolBarListener (Application controller, JButton add, JButton edit, JButton remove, JComboBox viewSelector, EventsView eV)
		{
			this.add=add;
			this.edit=edit;
			this.remove=remove;
			this.viewSelector=viewSelector;
			this.eV=eV;
			this.controller=controller;
		}
	
		public void actionPerformed(ActionEvent evt) {
			
			if (evt.getSource() == add)
			{
			  controller.addNewEvent(eV.getSelectedRow(),eV.getSelectedColumn());
			  return;
			}
			if (evt.getSource()==edit)	
			{
			 controller.editEvent(eV.getSelectedRow(),eV.getSelectedColumn());
			 return;
			}
			if (evt.getSource()==remove)
			{
				controller.removeEvent(eV.getSelectedRow(),eV.getSelectedColumn());
				return;
			}
			if (evt.getSource()==viewSelector)
			{
				controller.setView(viewSelector.getSelectedIndex());
			}
			
		}

	}